var t, e, n, o;

t = require("../siteinfo.js"), e = function(t) {
    return (t = t.toString())[1] ? t : "0" + t;
}, n = function(e, n, r, a, i) {
    var u = wx.getStorageSync("UserInfo"), s = null;
    u && (s = u.token);
    var g = "application/json";
    n.shop_id = t.shop_id;
    e.indexOf("getToken") > -1 && (g = "application/json"), e.indexOf("bindMobile") > -1 && (g = "application/x-www-form-urlencoded");
    var l = {
        "content-type": g,
        platformId: "10000",
        token: s,
        shop_id: t.shop_id,
        openId: u.openId,
        sessionKey: o("sessionKey")
    };
    wx.request({
        url: t.siteroot + e,
        data: n,
        method: i,
        header: l,
        success: function(t) {
            r(t);
        },
        fail: function(t) {
            a ? a(t) : wx.showToast({
                title: "加载信息失败"
            });
        }
    });
}, o = function(t) {
    return wx.getStorageSync(t);
}, module.exports = {
    formatNumber: e,
    formatTime: function(t) {
        var n = t.getFullYear(), o = (t.getMonth(), t.getDate()), r = t.getHours(), a = t.getMinutes(), i = t.getSeconds();
        return [ n, monthx, o ].map(e).join("/") + " " + [ r, a, i ].map(e).join(":");
    },
    formatTime1: function(t) {
        var n = new Date(t), o = new Date();
        return o.getFullYear() == n.getFullYear() && o.getMonth() == n.getMonth() && o.getDate() == n.getDate() ? e(n.getHours()) + ":" + e(n.getMinutes()) : o.getFullYear() != n.getFullYear() ? n.getFullYear() + "年" : e(n.getMonth() + 1) + "月" + e(n.getDate()) + "日";
    },
    formatTime2: function(t) {
        var n = new Date(t);
        return n.getFullYear() + "年" + e(n.getMonth() + 1) + "月" + e(n.getDate()) + "日 " + e(n.getHours()) + ":" + e(n.getMinutes());
    },
    requestGet: function(t, e, o, r) {
        n(t, e, o, r, "GET");
    },
    requestPost: function(t, e, o, r) {
        n(t, e, o, r, "POST");
    },
    showTip: function(t) {
        wx.showModal({
            title: "提示",
            content: t,
            showCancel: !1
        });
    },
    randomInt: function(t, e) {
        return Math.floor(Math.random() * (e - t + 1) + t);
    }
};